package top.ochiamalu.aioj.exception;

import top.ochiamalu.aioj.common.ErrorCode;

/**
 * throw 工具
 *
 * @author ochiamalu
 * @date 2025/01/24
 */
public final class ThrowUtils {
    private ThrowUtils() {
        throw new IllegalStateException("Utility class");
    }

    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    public static void throwIf(boolean condition, ErrorCode errorCode) {
        throwIf(condition, new BusinessException(errorCode));
    }

    public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
        throwIf(condition, new BusinessException(errorCode, message));
    }
}
